<template>
  <div>{{ userName }}</div>
  <n-button type="primary" @click="changeUserName">修改</n-button>
</template>

<script lang="ts">
  import { defineComponent, inject } from 'vue';
  import { NButton } from 'naive-ui';

  export default defineComponent({
    name: 'TimeLine',
    components: { NButton },
    setup() {
      let userName = inject('name');

      const changeUserName = () => {
        userName = '23';
      };
      return {
        userName,
        changeUserName,
      };
    },
  });
</script>
